****CONSTRUCT MIDLINE VARIABLES****

use "$data/midline_clean_merged.dta", clear
drop if a7>=400 & a7<500 // Drop Nganza b/c of conflict

*Payment of property tax

gen paid_receipt = pay_receipt==1
replace paid_receipt=0 if show_receipt==0
label var paid_receipt "Paid property tax (enumerator validated receipt)"

gen paid_union = paid_admin
replace paid_union =1 if paid_receipt ==1
label var paid_union "Paid property tax (primary measure)"

*Visits
gen visited = visited_dgrkoc==1|visited_dgrkoc==2
label var visited "Visited by collectors (self report)"

*Registration
gen registered = compound!=. & compound!=999999 
label var registered "Registered as taxpayer"

*Bribes
g any_bribe = arrange_nopay>0
replace any_bribe=0 if arrange_nopay==.
replace any_bribe=1 if arrange_pay>0 & arrange_pay!=.
replace any_bribe=0 if arrange_pay==0
replace any_bribe=. if visited_dgrkoc==0
label var any_bribe "Paid bribe (midline)"

save "$data/midline_clean_merged.dta", replace
